package cn.iocoder.yudao.module.fengdong.smartelderly.controller.app.activityrecord;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.activityrecord.vo.*;
import cn.iocoder.yudao.module.fengdong.smartelderly.convert.activityrecord.ActivityRecordConvert;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.activityrecord.ActivityRecordDO;
import cn.iocoder.yudao.module.fengdong.smartelderly.service.activityrecord.ActivityRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;

@Tag(name = "用户 APP - 活动参加记录")
@RestController
@RequestMapping("/fengdong.smartelderly/activity-record")
@Validated
public class AppActivityRecordController {

    @Resource
    private ActivityRecordService activityRecordService;

    @PostMapping("/create")
    @Operation(summary = "创建活动参加记录")
    public CommonResult<Long> createActivityRecord(@Valid @RequestBody ActivityRecordCreateReqVO createReqVO) {
        return success(activityRecordService.createActivityRecord(createReqVO));
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除活动参加记录")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteActivityRecord(@RequestParam("id") Long id) {
        activityRecordService.deleteActivityRecord(id);
        return success(true);
    }

    @GetMapping("/unitepage")
    @Operation(summary = "App---活动参加记录分页")
    public CommonResult<PageResult<ActivityRecordUniteRespVO>> getActivityRecordUnitePage(@Valid ActivityRecordUnitePageReqVO pageVO) {
        return success(activityRecordService.getActivityRecordUnitePage(pageVO));
    }
}
